<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>getting the width and heigh of an element</title>

    <style>
        .box {
            width: 100px;
            height: 150px;
            border: solid 5px #000;
            border-radius: 10%;
            padding: 10px;
            margin: 20px;
            background-color: red;
        }
    </style>
</head>

<body>
    <div class="box"></div>

    <script>
        let box = document.querySelector('.box');
        console.log(box.offsetWidth);// 120
        console.log(box.offsetHeight);// 170
        console.log(box.clientWidth);// 120
        console.log(box.clientHeight);// 170
        let domRect = box.getBoundingClientRect();// get the size of the element and its position relative to the viewport
        console.log(domRect);// DOMRect {x: 10, y: 10, width: 120, height: 170, top: 10, …}

        let width = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;// get the width of the viewport
        let height = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;// get the height of the viewport
        console.log(width, height);// 800 600
    </script>
</body>

</html>